const common = require('./webpack.common')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const merge = require('webpack-merge')

module.exports = merge(common, {
  mode: 'production',
  devtool: 'none',
  output: {
    filename: "js/[name].[contenthash:8].js",
  },
  optimization: {
    usedExports: true,
    minimize: true,
    concatenateModules: true,
    splitChunks: { // 代码分割
      chunks: "all"
    },
  },
  plugins: [
    new CleanWebpackPlugin(),
    new CopyWebpackPlugin(['public']),
    new HtmlWebpackPlugin({
      title: 'Vue Demo',
      template: './public/index.html',
      favicon: './public/favicon.ico',
      minify: { // 开启html压缩
        removeComments: true,
        collapseWhitespace: true,
        removeAttributeQuotes: true
      }
    })
  ]
})